import { PagedRequestDto } from "@shared/component-base";

export interface IChannelDto {
  id:number;
  name: string;
  channelGroupId: number;
  channelGroupName: string;
  content:string;
  keywords:string;
  description:string;
  isShowMenu:boolean;
  orderNo:number;
}

export class ChannelDto implements IChannelDto {
  id:number;
  name: string;
  channelGroupId: number;
  channelGroupName: string;
  content:string;
  keywords:string;
  description:string;
  isShowMenu:boolean;
  orderNo:number;

  constructor(data?: IChannelDto) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(data?: any) {
    if (data) {
      this.id = data["id"];
      this.name = data["name"];
      this.channelGroupId = data["channelGroupId"];
      this.channelGroupName = data["channelGroupName"];
      this.content = data["content"];
      this.keywords = data["keywords"];
      this.description = data["description"];
      this.isShowMenu = data["isShowMenu"];
      this.orderNo = data["orderNo"];
      
    }
  }

  static fromJS(data: any): ChannelDto {
    data = typeof data === 'object' ? data : {};
    let result = new ChannelDto();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["id"] = this.id;
    data["name"] = this.name;
    data["channelGroupId"] = this.channelGroupId;
    data["channelGroupName"] = this.channelGroupName;
    data["content"] = this.content;
    data["keywords"] = this.keywords;
    data["description"] = this.description;
    data["isShowMenu"] = this.isShowMenu;
    data["orderNo"] = this.orderNo;

    return data;
  }

  clone() {
    const json = this.toJSON();
    let result = new ChannelDto();
    result.init(json);
    return result;
  }
}

export class ChannelListQueryDto extends PagedRequestDto {
  phone: string;
  keywords: string;

  init(data?: any) {
    if (data) {
      this.pageIndex = data["pageIndex"];
      this.pageSize = data["pageSize"];
      this.sortField = data["sortField"];
      this.sortOrder = data["sortOrder"];
      this.keywords = data["keywords"];
    }
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["pageIndex"] = this.pageIndex;
    data["pageSize"] = this.pageSize;
    data["sortField"] = this.sortField;
    data["sortOrder"] = this.sortOrder;
    data["keywords"] = this.keywords;
    return data;
  }
}

export interface IChannelEditDto {
  id:number;
  name: string;
  channelGroupId: string;
  content:string;
  keywords:string;
  description:string;
  isShowMenu:boolean;
  orderNo:number;
}

export class ChannelEditDto implements IChannelEditDto {
  id: number;
  name: string;
  channelGroupId: string;
  content: string;
  keywords: string;
  description: string;
  isShowMenu: boolean;
  orderNo: number;

  constructor(data?: IChannelEditDto) {
    if (data) {
      for (var property in data) {
        if (data.hasOwnProperty(property))
          (<any>this)[property] = (<any>data)[property];
      }
    }
  }

  init(data?: any) {
    if (data) {
      this.id = data["id"];
      this.channelGroupId = data["channelGroupId"]+'';
      this.name = data["name"];
      this.content = data["content"];
      this.keywords = data["keywords"];
      this.description = data["description"];
      this.isShowMenu = data["isShowMenu"];
      this.orderNo = data["orderNo"];

    }
  }

  static fromJS(data: any): ChannelEditDto {
    data = typeof data === 'object' ? data : {};
    let result = new ChannelEditDto();
    result.init(data);
    return result;
  }

  toJSON(data?: any) {
    data = typeof data === 'object' ? data : {};
    data["id"] = this.id;
    data["channelGroupId"] = this.channelGroupId;
    data["name"] = this.name;
    data["content"] = this.content;
    data["keywords"] = this.keywords;
    data["description"] = this.description;
    data["isShowMenu"] = this.isShowMenu;
    data["orderNo"] = this.orderNo;

    return data;
  }

  clone() {
    const json = this.toJSON();
    let result = new ChannelEditDto();
    result.init(json);
    return result;
  }
}


